package com.hljx.controller;

import com.hljx.config.Result;
import com.hljx.entity.SysMenu;
import com.hljx.service.SysMenuService;
import com.hljx.vo.SysMenuVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 菜单权限表 前端控制器
 * </p>
 *
 * @author gx
 * @since 2023-09-26
 */
@RestController
@RequestMapping("/sysMenu")
@Tag(name = "菜单管理")
public class SysMenuController {

    @Autowired
    SysMenuService permissionService;

    @Operation(summary = "创建菜单")
    @PostMapping("/saveOrUpdateMenu")
    public Result<Boolean> saveOrUpdateMenu(@RequestBody SysMenu sysMenu) {
        return Result.success(permissionService.saveOrUpdateMenu(sysMenu));
    }

    @Operation(summary = "查询菜单")
    @GetMapping("/selectSysMenuVO")
    public Result<List<SysMenuVO>> selectSysMenuVO(@RequestParam(value = "menuName",required = false) String menuName) {
        return Result.success(permissionService.selectSysMenuVO(menuName));
    }

    @Operation(summary = "级联删除菜单")
    @GetMapping("/remove")
    public Result<Boolean> remove(@RequestParam("id") Long id) {
        return Result.success(permissionService.remove(id));
    }
}
